import random

import gradio

with gradio.Blocks() as demo:
    radio = gradio.Radio(["4", "5", "6"], label="Choose one")
    textbox = gradio.Textbox(lines=1, interactive=True)


    def change_line(value):
        if value == "4":
            # interactive 交互权限 决定用户能否修改内容
            # visible 视觉呈现 决定组件是否出现在界面上
            return gradio.Textbox(lines=4, interactive=True, visible=True)
        elif value == "5":
            return gradio.Textbox(lines=5, interactive=True, visible=True)
        elif value == "6":
            return gradio.Textbox(lines=6, interactive=True, visible=True)


    radio.change(fn=change_line, inputs=radio, outputs=textbox)

demo.launch()
